package com.ruoyi.yf.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.SysDept;
import com.ruoyi.yf.domain.YfDept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.yf.mapper.YfDistrictStatisticalMapper;
import com.ruoyi.yf.domain.YfDistrictStatistical;
import com.ruoyi.yf.service.IYfDistrictStatisticalService;
import com.ruoyi.common.core.text.Convert;

/**
 * 地区医废每日统计Service业务层处理
 * 
 * @author XiaoYi...
 * @date 2020-09-29
 */
@Service("yfDistrictStatisticalService")
public class YfDistrictStatisticalServiceImpl implements IYfDistrictStatisticalService 
{
    @Autowired
    private YfDistrictStatisticalMapper yfDistrictStatisticalMapper;

    /**
     * 查询地区医废每日统计
     * 
     * @param id 地区医废每日统计ID
     * @return 地区医废每日统计
     */
    @Override
    public YfDistrictStatistical selectYfDistrictStatisticalById(Long id)
    {
        return yfDistrictStatisticalMapper.selectYfDistrictStatisticalById(id);
    }

    /**
     * 查询地区医废每日统计列表
     * 
     * @param yfDistrictStatistical 地区医废每日统计
     * @return 地区医废每日统计
     */
    @Override
    public List<YfDistrictStatistical> selectYfDistrictStatisticalList(YfDistrictStatistical yfDistrictStatistical)
    {
        return yfDistrictStatisticalMapper.selectYfDistrictStatisticalList(yfDistrictStatistical);
    }

    /**
     * 新增地区医废每日统计
     * 
     * @param yfDistrictStatistical 地区医废每日统计
     * @return 结果
     */
    @Override
    public int insertYfDistrictStatistical(YfDistrictStatistical yfDistrictStatistical)
    {
        yfDistrictStatistical.setCreateTime(DateUtils.getNowDate());
        return yfDistrictStatisticalMapper.insertYfDistrictStatistical(yfDistrictStatistical);
    }

    /**
     * 修改地区医废每日统计
     * 
     * @param yfDistrictStatistical 地区医废每日统计
     * @return 结果
     */
    @Override
    public int updateYfDistrictStatistical(YfDistrictStatistical yfDistrictStatistical)
    {
        yfDistrictStatistical.setUpdateTime(DateUtils.getNowDate());
        return yfDistrictStatisticalMapper.updateYfDistrictStatistical(yfDistrictStatistical);
    }

    /**
     * 删除地区医废每日统计对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteYfDistrictStatisticalByIds(String ids)
    {
        return yfDistrictStatisticalMapper.deleteYfDistrictStatisticalByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除地区医废每日统计信息
     * 
     * @param id 地区医废每日统计ID
     * @return 结果
     */
    @Override
    public int deleteYfDistrictStatisticalById(Long id)
    {
        return yfDistrictStatisticalMapper.deleteYfDistrictStatisticalById(id);
    }


    // 批量添加地区统计
    @Override
    public void insertYfDistrictStatisticalList(List<YfDistrictStatistical> list) {
        yfDistrictStatisticalMapper.insertYfDistrictStatisticalList(list);
    }

    // 先根据地区及日期逻辑删除已经存在的统计
    @Override
    public void deleteYfDistrictStatisticalByDate(Long districtId, String date) {
        yfDistrictStatisticalMapper.deleteYfDistrictStatisticalByDate(districtId, date);
    }


    // 查询需要同步科室的医疗机构
    @Override
    public List<SysDept> getNeedSyncKSDeDept() {
        return yfDistrictStatisticalMapper.getNeedSyncKSDeDept();
    }

    // 根据暂存点ids及日期查询医废表中的科室
    @Override
    public List<YfDept> getKSListFromYFByStagingIds(Long[] stagingIds, String date) {
        return yfDistrictStatisticalMapper.getKSListFromYFByStagingIds(stagingIds, date);
    }

    // 根据医院id查询科室
    @Override
    public List<YfDept> getKSListFromKSTableByHospitalIds(Long[] hospitalIds) {
        return yfDistrictStatisticalMapper.getKSListFromKSTableByHospitalIds(hospitalIds);
    }

    // 把从医废表抓取的科室添加到科室表
    @Override
    public void insertKStoKSTable(YfDept yfDept) {
        yfDistrictStatisticalMapper.insertKStoKSTable(yfDept);
    }

}
